"""
内容:将分享封装成一个类

"""
#引入
from ECShop_no9.common.base import create_browser,Base,create_browser_op
import time


class PageCollect01(Base):

    #属性
    url = 'http://localhost:8080/ecshop/user.php'
    first = ('link text', '首页')
    sport_camera = ('xpath', ("//img[@src='images/201605/thumb_img/64_thumb_G_1462952811633.jpg']"))
    click_collect=("xpath",("//img[@src='themes/default/images/bnt_colles.gif']"))
    goods=("xpath",("//img[@src='themes/default/images/u5.gif']"))
    user = ('link text', '用户中心')
    goods_text=('link text','运动相机')
    #打开网页
    def page_collect_web(self):
        self.base_open_web(self.url)
    #点击首页
    def page_collect_first(self):
        self.base_click(self.first)
    #点击运动相机
    def page_collect_sport_camera(self):
        self.base_click(self.sport_camera)
    #点击收藏
    def page_collect_click_collect(self):
        self.base_click(self.click_collect)

    #点击弹窗
    #点击弹窗确定按钮
    def page_collect_click_pop(self):
        self.base_alert()

    #进入用户中心
    def page_collect_user(self):
        self.base_click(self.user)
    #进入收藏页面
    def page_collect_goods(self):
        self.base_click(self.goods)

    #获取收藏文本
    def page_collect_goods_text(self):
        result=self.base_get_text(self.goods_text)
        return result
    #关闭网页
    def page_collect_quit(self):
        self.base_quit()

if __name__ == '__main__':
    s1=PageCollect01(create_browser_op(r'C:\Users\lenovo\AppData\Local\Google\Chrome\User Data'))
    #打开网页
    s1.page_collect_web()
    #点击首页
    s1.page_collect_first()
    #点击运动相机
    s1.page_collect_sport_camera()
    time.sleep(4)
    #点击收藏
    s1.page_collect_click_collect()
    time.sleep(4)
    #点击弹窗确定
    s1.page_collect_click_pop()
    #进入用户中心
    s1.page_collect_user()
    #进入收藏页面
    s1.page_collect_goods()
    #获取文本
    print(s1.page_collect_goods_text())
